This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.
Update all callers.
columnview, NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
g_object_unref (selection);
- g_object_unref (treemodel);
name_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "name_column"));
sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
listview = gtk_list_view_new ();
gtk_widget_set_size_request (listview, 140, -1);
- model = G_LIST_MODEL (gtk_single_selection_new (G_LIST_MODEL (dialog->custom_paper_list)));
+ model = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (dialog->custom_paper_list))));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), model);
g_signal_connect (model, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
g_object_unref (model);
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (g_object_ref (model), NULL));
g_set_object (&self->filter_model, filter_model);
- g_object_unref (filter_model);
update_filter (self);
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), selection);
g_object_unref (selection);
- selection = G_LIST_MODEL (gtk_single_selection_new (model));
+ selection = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (model)));
g_set_object (&self->selection, selection);
g_object_unref (selection);
if (GTK_IS_SELECTION_MODEL (model))
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
else
- selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
+ selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (model)));
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
g_object_unref (selection);
- g_object_unref (filtered);
gtk_print_load_custom_papers (dialog->custom_paper_list);
/**
* gtk_single_selection_new:
- * @model: (transfer none): the #GListModel to manage
+ * @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
GtkSingleSelection *
gtk_single_selection_new (GListModel *model)
{
+ GtkSingleSelection *self;
+
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
- return g_object_new (GTK_TYPE_SINGLE_SELECTION,
+ self = g_object_new (GTK_TYPE_SINGLE_SELECTION,
"model", model,
NULL);
+
+ /* consume the reference */
+ g_clear_object (&model);
+
+ return self;
}
/**
create_model_for_object,
NULL,
NULL);
- wt->priv->selection = gtk_single_selection_new (G_LIST_MODEL (wt->priv->tree_model));
+ wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
G_LIST_MODEL (wt->priv->selection));
}
TRUE,
create_list_model_for_render_node_paintable,
NULL, NULL);
- recorder->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (recorder->render_node_model));
+ recorder->render_node_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (recorder->render_node_model)));
g_signal_connect (recorder->render_node_selection, "notify::selected-item", G_CALLBACK (render_node_list_selection_changed), recorder);
factory = gtk_signal_list_item_factory_new ();
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (rl->tree_model)), sorter));
rl->selection = gtk_single_selection_new (sort_model);
- g_object_unref (sort_model);
gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection));
GtkSelectionModel *result;
GString *changes;
- result = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (store)));
+ result = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (store))));
/* We want to return an empty selection unless autoselect is true,
* so undo the initial selection due to autoselect defaulting to TRUE.